feat(plugin-tools): ENG-12227 add remove button to ResourcesPickerButton#4510
feat(plugin-tools): ENG-12227 add remove button to ResourcesPickerButton#4510sanyamkamat merged 5 commits intomainfrom
Conversation
Commerce plugins (CommerceLayer, Shopify, SFCC, etc.) had no way to remove a selected resource once added. This adds a Close icon button next to the existing edit button that clears the selection and updates the content JSON, matching the pattern used by the reference field type. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
|
View your CI Pipeline Execution ↗ for commit 63b86d6
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Passing
nullinstead ofundefinedbypasses type contract- Changed props.onChange(null as any) to props.onChange(undefined) to match the CustomReactEditorProps type contract and ensure correct clearing behavior.
Or push these changes by commenting:
@cursor push d80dc52efe
Preview (d80dc52efe)
diff --git a/packages/plugin-tools/src/editors/ResourcesPicker.tsx b/packages/plugin-tools/src/editors/ResourcesPicker.tsx
--- a/packages/plugin-tools/src/editors/ResourcesPicker.tsx
+++ b/packages/plugin-tools/src/editors/ResourcesPicker.tsx
@@ -333,7 +333,7 @@
store.resourceHandle = undefined;
store.resourceId = undefined;
store.resourceInfo = null;
- props.onChange(null as any);
+ props.onChange(undefined);
})}
>
<Close css={{ color: '#888' }} />This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
|
@builderio-bot look at latest PR feedback and fix anything you agree with. Be skeptical. Reply to every comment if you fixed it or not and why |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9e09605. Configure here.
| export interface CustomReactEditorProps<T = any> { | ||
| value?: T; | ||
| onChange(val: T | undefined): void; | ||
| onChange(val: T | undefined | null): void; |
There was a problem hiding this comment.
value type excludes null despite onChange accepting it
Medium Severity
The onChange signature was updated to accept null, but value remains typed as T | undefined (via the ? modifier). After calling onChange(null), the framework will likely set value to null on re-render, but the type doesn't reflect this. Consumers checking typeof value === 'undefined' to detect an unset state (as done in ResourcesList.tsx) would incorrectly treat null as a set value. The value type needs to include null to match the onChange contract.
Reviewed by Cursor Bugbot for commit 9e09605. Configure here.



Commerce plugins (CommerceLayer, SFCC, etc.) had no way to remove a selected resource once added. This adds a Close icon button next to the existing edit button that clears the selection and updates the content JSON, matching the pattern used by the reference field type.
https://www.loom.com/share/10758e859af547dca10fad16fa4bb71e
Description
Summary
ResourcesPickerButtonso users can remove a selected resourceresourceHandle,resourceId,resourceInfoand callsonChange(null)to update the content JSON@builder.io/plugin-toolsTest plan
npm startScreenshot

If relevant, add a screenshot or two of the changes you made.
Before:
After fix:
Note
Medium Risk
Moderate risk because it changes the
CustomReactEditorProps.onChangetype to acceptnull, which may require downstream TypeScript updates, and adjusts CommerceLayer’s build pipeline dependencies/plugins.Overview
Adds a remove (Close/X) action to
ResourcesPickerButtonso a previously selected commerce resource can be cleared; it resets local selection state and callsonChange(null).Updates the shared editor prop type to allow
nullvalues, bumps@builder.io/plugin-toolsto0.0.10, and updates the CommerceLayer plugin to consume it while also tweaking Rollup config/deps (adds@rollup/plugin-commonjsand marks@builder.io/sdkas external).Reviewed by Cursor Bugbot for commit 63b86d6. Bugbot is set up for automated code reviews on this repo. Configure here.